<?php

/**
 * planning_phase form.
 *
 * @package    gesp
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class planning_phaseForm extends Baseplanning_phaseForm {
	public function configure() {
		unset($this['plnphs_date_fin']);
		unset($this['plnphs_charge_estimee']);
		unset($this['plnphs_charge_consommee']);
		unset($this['plnphs_charge_restante']);
		unset($this['plnphs_termine']);

		//-------------------------------------------------------------
		// redéfinition des widgets
		$this->setWidget('plnphs_prj_id', new sfWidgetFormInputHidden());
		$this->setWidget('plnphs_ordre', new sfWidgetFormInputHidden());
		$this->setWidget('plnphs_date_debut', new DatePickerWidget(array('default' => date('d/m/Y'))));
		$this->setWidget('plnphs_date_echeance', new DatePickerWidget());

		//-------------------------------------------------------------
		// redéfinition des validateurs
		$this->setValidator(
			'plnphs_date_debut',
			new ValidatorDate(array(
				'required' => true,
				'date_format' => '/^(?P<day>\d+)\/(?P<month>\d+)(\/(?P<year>\d+))?/',
				),
				array(
				'required' => 'Champ requis',
				'bad_format' => "format de date invalide : dd/mm[/yyyy]",
				)
			)
		);
		$this->setValidator(
			'plnphs_date_echeance',
			new ValidatorDate(array(
				'required' => false,
				'date_format' => '/^(?P<day>\d+)\/(?P<month>\d+)(\/(?P<year>\d+))?/',
				),
				array(
				'bad_format' => "format de date invalide : dd/mm[/yyyy]",
				)
			)
		);
		
		// contrôle par rapport aux tâches si modification
		$this->validatorSchema->setPostValidator(new sfValidatorAnd(array(
			new ValidatorPhasePlanning('plnphs_date_debut', array()),
			new ValidatorPhasePlanning('plnphs_date_echeance', array()),
		)));
		
		
		//-------------------------------------------------------------
		// redéfinition des libellés
		$this->widgetSchema->setLabels(array(
			'plnphs_ordre' => 'Ordre',
			'plnphs_libelle' => 'Libellé',
			'plnphs_date_debut' => 'Date de début',
			'plnphs_date_echeance' => 'Date d\'échéance',
		));
	}
}
